package com.example.test;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * TODO: 这里要写注释的!
 */
public class UserValidator {
    private String name;
    public UserValidator(String name){
        this.name= name;
    }
    public boolean validate(String name,String password){
        Random random= new Random();
        long duration= (long) (Math.random()*10);
        System.out.printf("Validator %s: validating a user during %d secondes\n",this.name,duration);
        try {
            TimeUnit.SECONDS.sleep(duration);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return random.nextBoolean();
    }

    public String getName(){
        return name;
    }
}
